package com.deep.test.designpattern.singleton.register;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * <p>Description:</p>
 * Created with IDEA
 * author:hudepin
 * createTime:2018/5/17 10:50
 */
public class RegisterMap {
    private RegisterMap(){}
    //线程安全
    private static Map<String,RegisterMap> registers = new ConcurrentHashMap<String,RegisterMap>();
    public static RegisterMap getInstance(String name){
        if(registers.containsKey(name)){
            return registers.get(name);
        }else{
            RegisterMap reg = new RegisterMap();
            registers.put(name,reg);
            return reg;
        }
    }
}
